#!/usr/bin/env python
# -*- coding: utf-8 -*-
###################################################################
# Author: wang donghao
# Date  : 2020.11
# Email : dd.parkhere@gmail.com
###################################################################
import os
import sys
from dayu_widgets.qt import *
from dayu_widgets.combo_box import MComboBox
from dayu_widgets.menu import MMenu
from dayu_widgets.push_button import MPushButton
from dayu_widgets.theme import MTheme


def set_hinter_info(this_win):
    internal = this_win.time_cb.currentText()
    if internal == u'关闭':
        this_win.q_settings.setValue('interval', 'off')
        return
    else:
        this_win.q_settings.setValue('interval', internal)


def main():
    this_win = QDialog()
    this_win.setWindowTitle(u'保存提醒弹幕设置')

    lay = QFormLayout()
    this_win.time_menu = MMenu()
    MTheme('light').apply(this_win.time_menu)
    this_win.time_menu.set_data(['5', '10', '20', '30', '40', '50', '60', u'关闭'])
    this_win.time_cb = MComboBox()
    this_win.time_cb.set_menu(this_win.time_menu)

    lay.addRow(u'设置提醒间隔', this_win.time_cb)

    main_lay = QVBoxLayout()
    this_win.setLayout(main_lay)
    main_lay.addLayout(lay)
    this_win.ok_pb = MPushButton(u'OK')
    main_lay.addWidget(this_win.ok_pb)
    this_win.ok_pb.clicked.connect(lambda: set_hinter_info(this_win))
    this_win.ok_pb.clicked.connect(this_win.close)

    this_win.q_settings = QSettings(u'ANIME_WOK_CONFIG', 'SaveHinter')
    return this_win
